home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / totdoc.zip / CHAPT7.TXT < prev    next >
Text File  |  1991-02-11  |  30KB  |  704 lines

  1.                                                                            Using
  2.                                                                          Windows
  3.  
  4.  
  5.          "A gentleman is a man who can play the accordian, but doesn't."
  6.  
  7.                                                                        Anonymous
  8.  
  9.  
  10. The Object Hierarchy
  11.  
  12.          All the objects discussed thus far are independent, i.e. no object has
  13.          any relationship with the others. However, the totWIN unit takes advan-
  14.          tage of an OOP facility known as inheritance.
  15.          Sometimes, a program just needs a quick pop-up window to display a
  16.          message. Other times you may want to display a window which can be
  17.          moved or dragged around the screen. Furthermore, in sophisticated pro-
  18.          grams, you may want windows which can be moved and stretched by drag-
  19.          ging the lower-right window corner.
  20.  
  21.          Using traditional Pascal you might create multiple window types, one to
  22.          handle each window style. Or, you might create a single powerful window
  23.          which is capable of providing the most sophisticated window needs, but
  24.          with features that can be disabled when simple windows are required.
  25.          Both of these solutions are clumsy and usually result in wasted code.
  26.          Using OOP, we can create a basic window object, and then create a
  27.          sibling window object which inherits all the properties of the basic
  28.          window, but which has some additional features. This new window object
  29.          can also have a sibling object which inherits the properties of the
  30.          window objects from which it is derived. By linking these window
  31.          objects together, an object hierarchy is formed. Figure 7.1 illustrates
  32.          the totWIN object hierarchy.
  33.          The four window objects have the following properties:
  34.  
  35.          WinOBJ         This basic window object paints a pop-up window on the
  36.                         display, with an optional shadow. Once the window has
  37.                         been displayed, all screen writing is restricted to
  38.                         within the window boundaries. Once the window is
  39.                         removed, the original (underlying) screen contents are
  40.                         restored, and the cursor is restored to its previous
  41.                         location and shape.
  42.          MoveWinOBJ     This object has all the properties of the basic window,
  43.                         but the window can also be moved around the screen. This
  44.                         is useful for pop-up messages and the like, because the
  45.                         user can move the message to another location to see the
  46.                         obscured part of the display.
  47.  
  48.          ScrollWinOBJ   This object has all the properties of the moveable
  49.                         window, but the window can also have optional scroll
  50.                         bars displayed on the right and lower window edges.
  51.  
  52.  
  53. 7-2                                                                 User's Guide
  54. --------------------------------------------------------------------------------
  55.  
  56.          StretchWinOBJ  This is the most sophisticated window object. It has all
  57.                         the properties of the other windows, but it can also be
  58.                         stretched and zoomed.
  59.  
  60. Figure 7.1                                                             [PICTURE]
  61. Window
  62. Object Hierarchy
  63.  
  64.  
  65.          When you want to display a window, just create an instance of the
  66.          appropriate window type and call the relevant window methods. For exam-
  67.          ple, the following code fragment creates a basic pop-up window and
  68.          displays the message "Hello Mum". (The individual methods will be
  69.          discussed in detail in later sections.) When the program is executed, a
  70.          simple window is displayed, and the user can exit by pressing [KEYCAP]
  71.          or by clicking the mouse on the close [*] icon.
  72.          program DemoWindowOne;
  73.          {DEMWI1}
  74.  
  75.          Uses DOS,CRT,
  76.               totFAST, totINPUT, totWIN;
  77.          var
  78.            MyWindow: WinOBJ;
  79.            K: word;
  80.            X,Y: byte;
  81.          begin
  82.             Screen.Clear(white,'░'); {paint the screen}
  83.             with MyWindow do
  84.             begin
  85.                Init;
  86.                Draw;
  87.                Screen.WriteLn('Hello Mum');
  88.                Repeat
  89.                   WinGetKey(K,X,Y);
  90.                until (K = 600) or (K= 27);
  91.                Done;
  92.             end;
  93.          end.
  94.  
  95.  
  96.          The following demo program, DEMWI2.PAS, is the same as the previous
  97.          demo, except that the window instance is of type MoveWinOBJ. This pro-
  98.          gram creates a moveable window. The user can move the window by holding
  99.          down the mouse button on the top row of the window and dragging the
  100.          window. The same effect can be achieved by pressing [KEYCAP]and using
  101.          the arrow keys. Pressing [KEYCAP] ends the keyboard move operation.
  102.          program DemoWindowTwo;
  103.          {DEMWI2 - a moveable window}
  104.  
  105.  
  106.  
  107. Using Windows                                                                7-3
  108. --------------------------------------------------------------------------------
  109.  
  110.          Uses DOS,CRT,
  111.               totFAST, totINPUT, totWIN;
  112.  
  113.          var
  114.            MyWindow: MoveWinOBJ;
  115.            K: word;
  116.            X,Y: byte;
  117.          begin
  118.             Screen.Clear(white,'░'); {paint the screen}
  119.             with MyWindow do
  120.             begin
  121.                Init;
  122.                Draw;
  123.                Screen.WriteLn('Hello Mum');
  124.                Repeat
  125.                   WinGetKey(K,X,Y);
  126.                until (K = 600) or (K= 27);
  127.                Done;
  128.             end;
  129.          end.
  130.  
  131.  
  132.  
  133. Window Attributes
  134.  
  135.          The color scheme used by all windows defaults to the colors defined in
  136.          the LookTOT^ instance. LookTOT^ also defines the special keys which are
  137.          used to move, stretch and zoom windows using the keyboard. By modifying
  138.          the LookTOT^ settings, you can quickly and easily change the default
  139.          window colors and special keys.
  140.          The two LookTOT^ methods which control the windows defaults are:
  141.  
  142.  
  143.          LookTOT^.SetWindow(Border,Body,Icons,Title: byte);
  144.          This method is used to specify the four window display attributes. All
  145.          windows have four basic color zones: the window border (where the box
  146.          is usually drawn), the main window body, the special mouse icons on the
  147.          top border, and the attributes for the title.
  148.  
  149.  
  150.          LookTOT^.SetWinKeys(Move,Stretch,Zoom: word);
  151.          This method is used to define the keys which can be used to move,
  152.          stretch and zoom a window. By default these keys are [KEYCAP], [KEYCAP]
  153.          and [KEYCAP]. A user without a mouse must use these keys to manipulate
  154.          a window.
  155.  
  156.          Refer to the LookTOT section on page 3-12 of chapter 3: Toolkit Basics
  157.          for further information.
  158.  
  159.  
  160.  
  161. 7-4                                                                 User's Guide
  162. --------------------------------------------------------------------------------
  163.  
  164.          You can, of course, change the default window display attributes for
  165.          any window instance. In other words, every window can have its own
  166.          unique color combinations. LookTOT^ is simply used to define the
  167.          default colors which will be used if no other colors are specified.
  168.  
  169.          Note: the special keys for window manipulation are not configurable for
  170.          each individual window. It would be confusing for the user if different
  171.          keys were used on different windows!
  172.  
  173.  
  174.          All windows optionally support shadows. The shadow characteristics are
  175.          controlled by the global instance ShadowTOT^. Refer to page 3-13 for
  176.          further information.
  177.  
  178.  
  179.  
  180.  
  181. Getting User Input
  182.          In the last chapter you learned that the KEY instance is used to deter-
  183.          mine user input. If you were observant, you may also have noticed that
  184.          some of the key codes in table 6.1 represented special window actions.
  185.          For example, code 600 indicates that the user selected the close window
  186.          icon.
  187.  
  188.          If there is a window on display, and you are waiting for user input,
  189.          call the window method WinGetKey, rather than the Key.GetInput method.
  190.          Behind the scenes, WinGetKey calls Key.GetInput. The user action is
  191.          then checked to see if the user is trying to perform a window specific
  192.          task, like clicking on the close icon, or moving the window. The window
  193.          object will automatically process the key if it is a window-related
  194.          task, and adjust the key to indicate the task performed. The following
  195.          key codes indicate some window activity took place:
  196.               600   Window closed
  197.               601   Window moved
  198.               602   Window re-sized
  199.               610   Scroll Up
  200.               611   Scroll Down
  201.               612   Scroll Left
  202.               613   Scroll Right
  203.               614   Vertical Elevator
  204.               615   Horizontal Elevator
  205.  
  206.  
  207.  
  208.           Note: if the key code indicates that the window has been re-sized or
  209.           scrolled, your application will need to refresh the window contents
  210.           as appropriate. Many of the other Toolkit units provide automatic
  211.  
  212.  
  213.  
  214. Using Windows                                                                7-5
  215. --------------------------------------------------------------------------------
  216.  
  217.           support for displaying items like lists, files and directories in a
  218.           window. All this screen refreshing and display management is handled
  219.           for you.
  220.  
  221.  
  222.  
  223.          The syntax of the WinGetKey method is as follows:
  224.  
  225.  
  226.          WinGetKey(var K:word; var X,Y: byte);
  227.          This method is passed 3 variable parameters. The first parameter will
  228.          be updated with the key the user pressed, and the second two parameters
  229.          will be updated with the (X,Y) coordinates of the mouse when the action
  230.          took place. If the key code is 614 or 615 (indicating the user clicked
  231.          the mouse in the scroll bar) the  (X,Y) coordinates represent the frac-
  232.          tion (X/Y) showing how far down to scroll.
  233.  
  234.          Refer back to the example on page 7.3, and you will notice that WinGet-
  235.          Key is called until the user selects the close icon (code 600) or
  236.          presses [KEYCAP] (code 27).
  237.  
  238.  
  239. Basic Windows
  240.  
  241.          The basic window object type is WinOBJ. Any WinOBJ instance is a static
  242.          pop-up window. Don't forget that every instance must be initialized
  243.          with the INIT method and disposed of with the DONE method. The DRAW
  244.          method is used to save the screen contents and display the window
  245.          frame. Any subsequent screen writes will be within the window. The
  246.          window can be removed with the method REMOVE, and the original screen
  247.          contents are then restored. Ordinarily, the window is automatically
  248.          removed when the DONE method is called.
  249.          There are a variety of WinOBJ methods for setting the window character-
  250.          istics, as follows:
  251.  
  252.  
  253.          SetSize(X1,Y1,X2,Y2,Style:byte);
  254.          When the window instance is initialized, the window is set with dimen-
  255.          sions (10,5) to (70,20) in a style of 1. The style parameter is the
  256.          same as the box style parameter discussed in chapter 5: Writing to the
  257.          Screen page 5-7. Call the method SetSize to customize the size and
  258.          style of the window.
  259.  
  260.  
  261.          SetTitle(Title:string);
  262.          Sets the window title. The window objects support the use of the title
  263.          prefix characters, as discussed on page 5-8. If the Title is too long,
  264.          it will be truncated to fit within the window boundaries.
  265.  
  266.  
  267.  
  268. 7-6                                                                 User's Guide
  269. --------------------------------------------------------------------------------
  270.  
  271.          SetColors(Border,Body,Title,Icons: byte);
  272.  
  273.          Use this method to customize the display attributes of the window. The
  274.          four parameters represent the combined foreground/background attributes
  275.          for the window border, window body, window title, and the close/zoom
  276.          icons respectively. If your program will be run on monochrome and color
  277.          systems, call the method Monitor^.ColorOn to decide whether to use
  278.          color or monochrome color combinations.
  279.  
  280.          SetRemove(On:boolean);
  281.  
  282.          By default, the window is removed when the method Done is called. Use
  283.          this method to control whether the window is removed or not. Pass TRUE
  284.          to activate the window removal, or FALSE to leave the window image on
  285.          the screen when Done is called.
  286.  
  287.          SetClose(On:boolean);
  288.  
  289.          This method controls whether the close icon [*] is drawn at the top
  290.          left of the window. Pass TRUE to enable it, or FALSE to disable it. By
  291.          default, the close icon is enabled.
  292.  
  293.          The following example, DEMWI3.PAS, shows how to use these basic window
  294.          methods, and figure 7.2 shows the generated screen image:
  295.  
  296.          program DemoWindowThree;
  297.          {DEMWI3 - WinOBJ settings}
  298.          Uses DOS,CRT,
  299.               totFAST, totINPUT, totWIN;
  300.  
  301.          var
  302.            MyWindow: WinOBJ;
  303.            K: word;
  304.            X,Y: byte;
  305.          begin
  306.             Screen.Clear(white,'░'); {paint the screen}
  307.             with MyWindow do
  308.             begin
  309.                Init;
  310.                SetSize(5,5,25,10,3);
  311.                SetTitle(' Greetings ');
  312.                SetClose(false);
  313.                SetRemove(false);
  314.                SetColors(94,95,89,80);
  315.                Draw;
  316.                Screen.WritePlain(1,1,'Hello Mum');
  317.                Repeat
  318.                   WinGetKey(K,X,Y);
  319.                until (K=27);
  320.  
  321.  
  322. Using Windows                                                                7-7
  323. --------------------------------------------------------------------------------
  324.  
  325.                Done;
  326.             end;
  327.          end.
  328.  
  329. Figure 7.2                                                              [SCREEN]
  330. A WinOBJ
  331. Example
  332.  
  333.          The following WinOBJ function methods return information about the cur-
  334.          rent window settings:
  335.  
  336.  
  337.          GetSize(var X1,Y1,X2,Y2,Style: byte);
  338.          This method is passed five variable parameters which are updated with
  339.          the current window coordinates and style.
  340.  
  341.  
  342.          GetX: byte;
  343.          Returns the X coordinate of the upperleft window corner.
  344.  
  345.  
  346.          GetY: byte;
  347.          Returns the Y coordinate of the upperleft window corner.
  348.  
  349.  
  350.          GetStyle: byte;
  351.          Returns the window style.
  352.  
  353.  
  354.          GetBorderAttr: byte;
  355.          Returns the display attribute of the window border.
  356.  
  357.  
  358.          GetBodyAttr: byte;
  359.          Returns the display attribute of the main window area.
  360.  
  361.  
  362.          GetIconsAttr: byte;
  363.          Returns the display attribute of the window close and zoom icons.
  364.  
  365.  
  366.          GetTitleAttr: byte;
  367.          Returns the display attribute of the window title.
  368.  
  369.  
  370.          GetRemoveStatus: boolean;
  371.  
  372. 7-8                                                                 User's Guide
  373. --------------------------------------------------------------------------------
  374.  
  375.          Returns true if the window will be removed when the Done method is
  376.          called.
  377.  
  378.  
  379.          Once you have initialized the window and assigned the appropriate set-
  380.          tings, the window is ready to be displayed. To display the window, use
  381.          one of the following two methods:
  382.  
  383.  
  384.          Draw;
  385.          The window is displayed, and the cursor is moved to the top left corner
  386.          of the window.
  387.  
  388.  
  389.          GrowDraw;
  390.          This is the same as draw, except that the window g.r..o..w...s onto the
  391.          screen for a special effect.
  392.  
  393.  
  394.          Once the window has been drawn, use the standard Screen methods to
  395.          write to the window. Note that the upperleft coordinate of the inner
  396.          part of the window is (1,1). Refer to page 5-16 for a discussion of
  397.          window coordinates.
  398.          The following method, Remove, can be used to remove the window:
  399.  
  400.  
  401.          Remove;
  402.          Restores the original screen contents as well as the cursor location
  403.          and shape. If window coordinates were active when the window was drawn,
  404.          the previous window coordinates are restored.
  405.  
  406.  
  407.          The Remove method is automatically called if the DONE method is called,
  408.          if the remove setting is true and if the window is still on display.
  409.          The Done method also disposes of any memory used by the window.
  410.  
  411.  
  412.  
  413. Moveable Windows
  414.          A moveable window is like the static windows just described, except
  415.          that the user can move the window to any location on the screen. Remem-
  416.          ber that a user can move the window by holding down the left mouse
  417.          button on the top window border (making sure not to hit a window icon),
  418.          and dragging the window around the display. The same result can be
  419.          achieved by pressing the move hotkey (defined in LOOKtot^), which
  420.          defaults to [KEYCAP]. The window can then be moved by pressing the
  421.          cursor keys, and the move is completed by pressing [KEYCAP].
  422.  
  423.  
  424.  
  425. Using Windows                                                                7-9
  426. --------------------------------------------------------------------------------
  427.  
  428.          A moveable window is created by declaring an instance of type MoveWi-
  429.          nOBJ. Moveable windows share all the properties of static windows, and
  430.          all the previously described methods are available. Moveable windows
  431.          have the following two methods which restrict window movement:
  432.  
  433.  
  434.          SetBoundary(X1,Y1,X2,Y2:byte);
  435.          This method controls the area of the screen in which the window can be
  436.          moved. By default, this boundary is the entire screen. Use this method
  437.          to stop the user from placing the window on top of some information you
  438.          want to be displayed. For example, the following statement will keep
  439.          the window away from the top and bottom display lines:
  440.          SetBoundary(1,2,80,24);.
  441.  
  442.  
  443.          SetAllowMove(On:boolean);
  444.          Not too surprisingly, by default, the Toolkit allows the user to move
  445.          moveable windows. This method allows you to restrict, and later, enable
  446.          window movement. Pass a False parameter to stop window movement, and a
  447.          True to enable movement. Circumstances under which you might use this
  448.          routine; you are using other Toolkit units, which themselves use move-
  449.          able windows, but you want to disable movement. For example, message,
  450.          list and browse objects.
  451.  
  452.  
  453.          Refer back to DEMWI2.PAS on page 7.3 for an example of a moveable
  454.          window.
  455.  
  456.  
  457. Windows with Scroll Bars
  458.  
  459.          If you have run some of the larger Toolkit demo programs, you may have
  460.          noticed the scroll bars on some of the window boundaries. The scroll
  461.          bars provide a way for the user to scroll a window's contents using the
  462.          mouse. Various units in the Toolkit (discussed in later chapters) pro-
  463.          vide comprehensive support for displaying files, directories and lists
  464.          in windows with scroll bars. However, if these objects don't meet your
  465.          needs, you can build your own scrollable window using the ScrollWinOBJ
  466.          object.
  467.          ScrollWinOBJ is a descendant of MoveWINOBJ, and so shares all the prop-
  468.          erties and methods of the moveable windows just discussed. In essence,
  469.          a scrollable window is simply a moveable window with scroll bars (see
  470.          figure 7.3).
  471.  
  472.  
  473. Figure 7.3                                                              [SCREEN]
  474. A Scrollable
  475. Window
  476.  
  477.  
  478.  
  479.  
  480. 7-10                                                                User's Guide
  481. --------------------------------------------------------------------------------
  482.  
  483.          Scrollable windows support both horizontal and/or vertical scroll bars,
  484.          which can be activated by calling the following method:
  485.  
  486.  
  487.          SetScrollable(Vert,Horiz:boolean);
  488.          This method controls which scroll bars are drawn; the first parameter
  489.          controls the vertical scroll bar, and the second the horizontal one.
  490.          Pass a TRUE to instruct the window to display the scroll bars. By
  491.          default, both scroll bars are disabled, i.e. set to false.
  492.  
  493.  
  494.          The sliding elevator in the body of the scroll bar gives the user a
  495.          visual indication of which part of the data is currently being dis-
  496.          played in the window. For example, if the window is displaying a file
  497.          and the elevator is at the top of the scroll bar, the user must be
  498.          looking at the first part of the file. As the user scrolls down, the
  499.          elevator will jump down in increments. When the end of the file is
  500.          being viewed, the elevator will be at the bottom of the scroll bar.
  501.          Similary, the horizontal elevator will show the relative lateral posi-
  502.          tion of the window, e.g. how far along the line is being viewed.
  503.          Whenever you change the contents of a scrollable window, you should
  504.          re-draw the scroll bar(s) to show the relative location of the dis-
  505.          played data. The methods DrawHorizBar and DrawVertBar are used for this
  506.          purpose. When a scroll bar is re-drawn, the Toolkit must be instructed
  507.          where to position the elevator. This is achieved by passing two parame-
  508.          ters to the drawing methods. The first parameter represents the current
  509.          value (or location), and the second is the maximum value. For example,
  510.          if you are browsing a 1000 line file, and the first line visible in the
  511.          window is 265, the passed parameters would be (265,1000).
  512.  
  513.          The syntax of the scroll bar drawing methods is as follows:
  514.  
  515.          DrawHorizBar(Current,Max:longint);
  516.  
  517.          Draws a horizontal scroll bar at the bottom of the window and positions
  518.          the elevator based on the fraction (Current/Max).
  519.  
  520.          DrawVertBar(Current,Max: longint);
  521.  
  522.          Draws a vertical scroll bar at the right of the window and positions
  523.          the elevator based on the fraction (Current/Max).
  524.  
  525.  
  526.          Once you have initially displayed the window, call the method WinGet-
  527.          Key(K,X,Y); (discussed on page 7-4) to determine the user action. The
  528.          following key codes indicate some scrolling activity:
  529.  
  530.  
  531. Using Windows                                                               7-11
  532. --------------------------------------------------------------------------------
  533.  
  534.               610   Scroll Up
  535.               611   Scroll Down
  536.               612   Scroll Left
  537.               613   Scroll Right
  538.               614   Vertical Elevator
  539.               615   Horizontal Elevator
  540.  
  541.  
  542.          You should re-draw the window contents based on the action requested by
  543.          the user. The codes 614 and 615 indicate the user clicked the left
  544.          mouse button on the body of the scroll bar. This means the user wants
  545.          to jump to a different part of the data. The X and Y parameters
  546.          returned from WinGetKey indicate which data to display. The X coordi-
  547.          nate represents the number of characters along from the top (or left)
  548.          of the scroll bar where the user clicked the mouse. The Y coordinate
  549.          indicates the total length of the scroll bar.
  550.          For example, if the X and Y parameters are returned as 5 and 15,
  551.          respectively, you need to display the data which is 5/15ths of the way
  552.          from the top of the data. In our example of a 1000 line text file, you
  553.          would need to display the lines commencing with line 333, i.e.
  554.          (5/15)*1000.
  555.  
  556.          Having re-drawn the window contents, don't forget to re-draw the scroll
  557.          bars.
  558.  
  559.            Note: only window styles 1 through 5 support scrollable windows.
  560.            If the style is set to any other value, the window will use style
  561.            1.
  562.  
  563.  
  564.  
  565.  
  566.  
  567. Stretchable Windows
  568.  
  569.          The most flexible form of window supported by the Toolkit is called a
  570.          stretchable window. A stretchable window is a moveable window, the
  571.          dimensions of which can also be changed. A user can change the size of
  572.          a stretchable window by pressing down the left mouse button on the
  573.          lower right corner of the window and dragging the corner to the desired
  574.          location. The same result can be achieved by pressing the stretch
  575.          hotkey (defined in LOOKtot^), which defaults to [KEYCAP]. The window
  576.          can then be moved by pressing the cursor keys, and the move is com-
  577.          pleted by pressing [KEYCAP].
  578.          A user can also zoom the window to its full size by clicking on the
  579.          zoom icon, located at the top right of the window. When the window is
  580.  
  581.  
  582.  
  583. 7-12                                                                User's Guide
  584. --------------------------------------------------------------------------------
  585.  
  586.          fully zoomed, it can be restored to its pre-zoom dimensions by clicking
  587.          on the zoom icon a second time. The default zoom and un-zoom key is
  588.          [KEYCAP].
  589.  
  590.          To create a stretchable window, create an object instance of type
  591.          StretchWinOBJ. This object is descendant from ScrollWinOBJ and so
  592.          shares all its characteristics and methods.
  593.          The coordinates of a full zoomed window are defined with the SetBounda-
  594.          ries method described in the previous section. The following method is
  595.          used to control the minimum window size:
  596.  
  597.  
  598.          SetMinSize(Width,Depth: byte);
  599.          The two parameters set the minimum width and depth of the window in
  600.          characters. By default, the minimum is 10 characters wide by 5 charac-
  601.          ters deep.
  602.  
  603.  
  604.          The following method can be used to control whether the user is allowed
  605.          to stretch and zoom the window:
  606.  
  607.          SetAllowStretch(On:boolean);
  608.  
  609.          Pass a False parameter to disable window stretching, or a True parame-
  610.          ter to enable window stretching. When stretching is disabled, the size
  611.          of the window cannot be changed with either the mouse or the keyboard.
  612.  
  613.          Whenever a user stretches or zooms a window, the window is re-drawn
  614.          with the new dimensions, and the body of the window is cleared. You
  615.          must then rewrite the window contents, and re-draw the scroll bars.
  616.          WinGetKey will return a code of 602 if the user has re-sized the win-
  617.          dow.
  618.  
  619.          Listed below is the demo program DEMWI4.PAS which provides a framework
  620.          for building your own scrollable window routines.
  621.          program DemoWindowFour;
  622.          {DEMWI4 - a StretchWinOBJ template}
  623.  
  624.          Uses DOS,CRT,
  625.               totFAST, totINPUT, totWIN;
  626.          var
  627.            MyWindow: StretchWinOBJ;
  628.            K: word;
  629.            X,Y: byte;
  630.  
  631.  
  632.  
  633. Using Windows                                                               7-13
  634. --------------------------------------------------------------------------------
  635.  
  636.          procedure ScreenRefreshProc;
  637.          {This procedure would refresh the screen contents}
  638.          begin
  639.             Screen.WritePlain(1,1,'Fresh Screen');
  640.             {...}
  641.             MyWindow.DrawHorizBar(1,100); {the parameters should reflect}
  642.             MyWindow.DrawVertBar(1,100);  {the data position of the window}
  643.          end;
  644.  
  645.          procedure ScrollUpProc;
  646.          begin
  647.          end;
  648.          procedure ScrollDownProc;
  649.          begin
  650.          end;
  651.  
  652.          procedure ScrollLeftProc;
  653.          begin
  654.          end;
  655.          procedure ScrollRightProc;
  656.          begin
  657.          end;
  658.  
  659.          procedure ScrollJumpVertProc(X,Y:byte);
  660.          begin
  661.          end;
  662.          procedure ScrollJumpHorizProc(X,Y:byte);
  663.          begin
  664.          end;
  665.  
  666.          begin
  667.             Screen.Clear(white,'░'); {paint the screen}
  668.             with MyWindow do
  669.             begin
  670.                Init;
  671.                SetTitle(' Template ');
  672.                SetBoundary(1,1,80,24);
  673.                SetScrollable(true,true);
  674.                Draw;
  675.                ScreenRefreshProc;
  676.                Repeat
  677.                   WinGetKey(K,X,Y);
  678.                   case K of
  679.                   602: ScreenRefreshProc;
  680.                   610: ScrollUpProc;
  681.                   611: ScrollDownProc;
  682.                   612: ScrollLeftProc;
  683.                   613: ScrollRightProc;
  684.                   614: ScrollJumpVertProc(X,Y);
  685.  
  686.  
  687. 7-14                                                                User's Guide
  688. --------------------------------------------------------------------------------
  689.  
  690.                   615: ScrollJumpHorizProc(X,Y);
  691.                   end;
  692.                until (K=27) or (K=600);
  693.                Done;
  694.             end;
  695.          end.
  696.  
  697.  
  698.          In Part 2: Extending the Toolkit, techniques for creating objects
  699.          descendant from ScrollWinOBJ are discussed. Specifically, the text
  700.          describes how to create an object for scrolling a virtual screen within
  701.          a window.
  702.  
  703.  
  704.